Skip to content

Causal LM tokenization: Chunking and seq2seq Forward - #206

Merged
alex-jw-brooks merged 23 commits into
caikit:mainfrom
alex-jw-brooks:causal_lm_tok_toggle
Oct 2, 2023
Merged

Causal LM tokenization: Chunking and seq2seq Forward#206
alex-jw-brooks merged 23 commits into
caikit:mainfrom
alex-jw-brooks:causal_lm_tok_toggle

Conversation

@alex-jw-brooks

@alex-jw-brooks alex-jw-brooks commented Sep 25, 2023

Copy link
Copy Markdown
Collaborator

This PR is the nth rewrite of causal language modeling tokenization, now changing it to:

  • Let us use sequence type tokenization with causal language models if we want to
  • Or enable chunking on the concatenated sequence, optionally dropping the remainder if the chunks are uneven

Sequence type tokenization is a port of the old causal LM tokenization logic with a bug fix for the concatenation sequence length; I have verified the quality matches approximately what we would expect from prompt tuning on RTE.

Chunking seems to be functional and has tests verifying output correctness but is not publicly exposed yet and therefore has not fully quality tested.

We need to be careful about collator compatibility when changing the chunking strategy, since prompt tuning and the base model resources/text generation currently manage collators for different model types differently. The main thing to be wary of is that the causal language modeling collator should not be used with the sequence approach to avoid clobbering the labels.

Note that currently things are still being statically padded and using the default collator; it would be more ideal to:

  • use the padding collator for dynamic padding when possible
  • add better collator based tests operating on transformers datasets; this PR does start these tests a bit, but only covers the default collator, which does not necessarily need a torch dataset to work

@alex-jw-brooks alex-jw-brooks changed the title Causal lm tok toggle Causal LM tokenization: Chunking and seq2seq Forward Sep 25, 2023
@alex-jw-brooks
alex-jw-brooks force-pushed the causal_lm_tok_toggle branch 2 times, most recently from f590817 to 892a6d1 Compare September 28, 2023 22:05
@alex-jw-brooks
alex-jw-brooks marked this pull request as ready for review September 29, 2023 17:52
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
NOTE: If mlm (masked language modeling) is not passed in kwargs,
this function will automatically set it to `False`.

FIXME: This should be consolidated with what is in the prompt tuning

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, this will cause a little bit of conflict with #203 PR as I am refactoring there to use common functions instead of separate data collators and processing functions 🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Obviously the static padding stuff isn't great, but I imagine we probably want to use the same collators everywhere anyway, right? I.e., fine tuning tokenization logic is the same

Comment thread caikit_nlp/resources/pretrained_model/hf_auto_causal_lm.py
Comment thread caikit_nlp/resources/pretrained_model/hf_auto_causal_lm.py
Comment thread caikit_nlp/modules/text_generation/text_generation_local.py
NOTE: If mlm (masked language modeling) is not passed in kwargs,
this function will automatically set it to `False`.

FIXME: This should be consolidated with what is in the prompt tuning

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Obviously the static padding stuff isn't great, but I imagine we probably want to use the same collators everywhere anyway, right? I.e., fine tuning tokenization logic is the same

Comment thread caikit_nlp/resources/pretrained_model/hf_auto_causal_lm.py
Comment thread caikit_nlp/resources/pretrained_model/hf_auto_causal_lm.py

@gkumbhat gkumbhat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks Alex. The default for now for seq2seq make sense. Lets get the other changes validated and working iteratively and then enable that option. For now, getting this in to unblock causal-lm prompt tuning.

Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
@alex-jw-brooks
alex-jw-brooks merged commit 24de8fb into caikit:main Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants